@extends('backend::layout')
@section('title',trans($page_title))
@section('content')
    @if(isset($search_tpl))
        {{$search_tpl->render()}}
    @endif
    @component('backend::component.table.table-content')
        @slot('page_title') {{$page_title}} @endslot
        @slot('tools_btn')
            @component('backend::component.form.button')
                @slot('title') 添加会员 @endslot
                @slot('elem') a @endslot
                @slot('btn') btn @endslot
                @slot('color') danger @endslot
                @slot('icon') hcl-user-add @endslot
                @slot('href') {{route('b_User_createUser')}} @endslot
            @endcomponent
           @component('backend::component.form.button')
               @slot('title') 导出会员 @endslot
               @slot('attr') onclick=exportData(this) @endslot
               @slot('color') info @endslot
               @slot('icon') hcl-export @endslot
               @slot('params'){"url":"{{route('b_User_exportUserData')}}","method":"post","title":"批量导出","targetData":".id","confirm":"true"} @endslot
           @endcomponent


        @endslot
        @slot('body_content')
            @if($list->isNotEmpty())
                <table class="list table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>
                            @component('backend::component.checkbox')
                                @slot('name') ids-all @endslot
                            @endcomponent
                        </th>
                        <th>账号</th>
                        @foreach($currencies as $name=>$title)
                            <td>{{$title}}</td>
                        @endforeach
                        <th>推荐人</th>
                        <th>节点人</th>
                        <th>级别</th>
                        <th>粉丝级别</th>
                        <th>车队级别</th>
                        <th>贡献值/活跃值</th>
                        <th>油补</th>
                        <th>时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($list as $value)
                        <tr>
                            <td>
                                @component('backend::component.checkbox')
                                    @slot('name') user_id[] @endslot
                                    @slot('class') id @endslot
                                    @slot('value') {{$value->member_id}} @endslot
                                @endcomponent
                            </td>
                            <td>
                                {{$value->user_number}}<br/>
                                [{{$value->real_name}}]<br/>
                                [{{$value->user_phone}}]
                            </td>

                            @foreach($currencies as $name=>$title)
                                <td>{{$value->wallet->{$name} ?? 0 }}</td>
                            @endforeach
                            <td>
                                @if($value->referrer)
                                    {{$value->referrer->user_number}}<br/>
                                    [{{$value->referrer->real_name}}]<br/>
                                    [{{$value->referrer->user_phone}}]
                                @else
                                    无推荐人
                                @endif
                            </td>
                            <td>
                                @if($value->jiedian)
                                    {{$value->jiedian->user_number}}<br/>
                                    [{{$value->jiedian->real_name}}]<br/>
                                    [{{$value->jiedian->user_phone}}]
                                @else
                                    无节点人
                                @endif
                            </td>

                            <td>{{get_user_level($value->level)}}</td>
                            <td>{{get_user_fs_level($value->fs_level)}}</td>
                            <td>{{get_user_cd_level($value->cd_level)}}</td>
                            <td>
                                贡献值/活跃值：{{$value->num_zt_yx}}/{{$value->num_td_yx}}
                            </td>
                            <td>
                                当前每日油补：{{$value->gz_day_val??0}}<br/>
                                当前级别可领天数：{{$value->gz_day_can??0}}<br/>
                                当前级别已领天数：{{$value->gz_day_had??0}}
                            </td>

                            <td>
                                注册时间：{{$value->created_at}}<br/>
{{--                                激活时间：{{$value->activated_at}}--}}
                            </td>
                            <td>
{{--                                @if($value->is_real_name<1)--}}
{{--                                    @component('backend::component.form.button')--}}
{{--                                        @slot('title') 认证通过 @endslot--}}
{{--                                        @slot('icon') hcl-user-sp @endslot--}}
{{--                                        @slot('color') danger @endslot--}}
{{--                                        @slot('params') {"url":"{{route('b_User_agreeRealName',['user_id'=>$value->member_id])}}","confirm":"true"} @endslot--}}
{{--                                        @slot('class') btn-ajax @endslot--}}
{{--                                    @endcomponent--}}
{{--                                @endif--}}

                                @component('backend::component.form.button')
                                    @slot('title') 禁用 @endslot
                                    @slot('icon') hcl-user-ban @endslot
                                    @slot('color') danger @endslot
                                    @slot('params') {"url":"{{route('b_User_freezeUser',['id'=>$value->member_id])}}","confirm":"true"} @endslot
                                    @slot('class') btn-ajax @endslot
                                @endcomponent


                                @if(!$value->is_bd)
                                @component('backend::component.form.button')
                                    @slot('title') 删除 @endslot
                                    @slot('icon') hcl-user-ban @endslot
                                    @slot('color') danger @endslot
                                    @slot('params') {"url":"{{route('b_User_deleteUser',['user_id'=>$value->member_id])}}","confirm":"true"} @endslot
                                    @slot('class') btn-ajax @endslot
                                @endcomponent
                                @endif

                                @component('backend::component.form.button')
                                    @slot('title') 访问前台 @endslot
                                    @slot('elem') a @endslot
                                    @slot('icon') hcl-browser @endslot
                                    @slot('attr') target=_blank @endslot
                                    @slot('color') primary @endslot
                                    @slot('href') {{route('b_User_visitFrontend',['user_id'=>$value->member_id])}} @endslot
                                @endcomponent

                                @component('backend::component.form.button-group')
                                        @slot('button_title')
                                            @component('backend::component.form.button')
                                                @slot('title') 更多 @endslot
                                                @slot('color') primary @endslot
                                                @slot('size') sm @endslot
                                                @slot('icon') hcl-more @endslot
                                                @slot('class') dropdown-toggle @endslot
                                                @slot('attr') data-toggle=dropdown @endslot
                                            @endcomponent
                                        @endslot
                                        @slot('button_item')
                                                @component('backend::component.form.button')
                                                    @slot('title') 详情 @endslot
                                                    @slot('elem') a @endslot
                                                    @slot('class') dropdown-item @endslot
                                                    @slot('color') info @endslot
                                                    @slot('href') {{route('b_User_infoUser',['id'=>$value->member_id])}} @endslot
                                                @endcomponent

                                            @component('backend::component.form.button')
                                                @slot('title') 编辑 @endslot
                                                @slot('elem') a @endslot
                                                @slot('class') dropdown-item @endslot
                                                @slot('href') {{route('b_User_editUser',['id'=>$value->member_id])}} @endslot
                                            @endcomponent

                                            @component('backend::component.form.button')
                                                @slot('title') 留言 @endslot
                                                @slot('elem') a @endslot
                                                @slot('class') dropdown-item @endslot
                                                @slot('href') {{route('b_Message_send',['user_id'=>$value->member_id])}} @endslot
                                            @endcomponent
                                            @component('backend::component.form.button')
                                                @slot('title') 账户校正 @endslot
                                                @slot('elem') a @endslot
                                                @slot('class') dropdown-item @endslot
                                                @slot('href') {{route('b_Account_correctAccount',['user'=>$value->user_number])}} @endslot
                                            @endcomponent
                                        @endslot
                                @endcomponent
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                @slot('list_page')
                    {{$list->appends($search_tpl->getSearchData())->links('backend::public.pagination')}}
                @endslot
            @else
                @component('backend::public.empty_page')
                    @slot('info') 暂时没有会员 @endslot
                @endcomponent
            @endif
        @endslot
    @endcomponent
@endsection
@push('scripts')
<script type="text/javascript">
    layui.use(['jquery','layer'], function() {
        var layer = layui.layer,
            $ = layui.jquery;
        $('.change_user').off('click').on('click',function () {
            var _that = this;
            var params = $(_that).data('params');
            var num_type = params.type ;
            var typeText = ''
            if(parseInt(num_type) == 1){
                typeText = "代理"
            }else{
                typeText = "运营中心"
            }
            layer.confirm('确定要修改会员【'+params.real_name+'】的'+typeText+'身份?', function(index){
                $.ajax({
                    type: params.method,
                    url: params.url,
                    data: {'real_name': params.real_name, 'type': num_type,'value':params.value},
                    dataType: "json",
                    success: function (response) {
                        if (response.status) {
                            layer.msg(response.msg, {icon: 6});
                            setTimeout(function () {
                                location.href = response.url;
                            }, 2000);
                        } else {
                            layer.msg(response.msg, {icon: 5});
                        }
                    }
                })
                layer.close(index);
            });

        });

    });
</script>
@endpush